#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <cstring>

struct Student {
    char name[30];
    int month;
    int day;
} students[200];


bool MyCompare(const Student& p1, const Student& p2) {
    if (p1.month != p2.month) {
        return p1.month < p2.month;
    }
    if (p1.day != p2.day) {
        return p1.day < p2.day;
    }
    int len1 = strlen(p1.name);
    int len2 = strlen(p2.name);
    if (len1 != len2) {
        return len1 < len2;
    }

    return strcmp(p1.name, p2.name) < 0;
}

/**
 * 
 * 时间复杂度：O(nlogn)
 * 空间复杂度：O(n)
 * 
 * 生日相同
 * 
 * @return
 */
int main() {

    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s %d %d", students[i].name, &students[i].month, &students[i].day);
    }

    std::sort(students, students + n, MyCompare);

    bool hasDuplicates = false;

    for (int i = 0; i < n;) {
        int j = i + 1;
        while (j < n && students[j].month == students[i].month && students[j].day == students[i].day) {
            j++;
        }

        if (j - i > 1) {
            hasDuplicates = true;
            printf("%d %d", students[i].month, students[i].day);
            for (int k = i; k < j; k++) {
                printf(" %s", students[k].name);
            }
            printf("\n");
        }
        i = j;
    }

    if (!hasDuplicates) {
        printf("None\n");
    }

    return 0;
}



